<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>分步表单</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" th:href="@{/layuimini/lib/layui-v2.5.5/css/layui.css}" media="all">
    <link rel="stylesheet" th:href="@{/layuimini/css/public.css}" media="all">
    <link rel="stylesheet" th:href="@{/layuimini/js/lay-module/step-lay/step.css}" media="all">
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
            <legend>管理员添加</legend>
        </fieldset>

        <form class="layui-form" action="" lay-filter="example">
            <div class="layui-form-item">
                <label class="layui-form-label">管理员</label>
                <div class="layui-input-block">
                    <input type="text" name="username" lay-verify="title" autocomplete="off" placeholder="请输入用户名" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">密码</label>
                <div class="layui-input-block">
                    <input type="password" name="password" placeholder="请输入密码" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">确定密码</label>
                <div class="layui-input-block">
                    <input type="password" name="password_qd" placeholder="请输入密码" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">管理员备注</label>
                <div class="layui-input-block">
                    <textarea placeholder="请输入内容" class="layui-textarea" name="desc"></textarea>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
                </div>
            </div>
        </form>

    </div>
</div>
<script th:src="@{/layuimini/lib/layui-v2.5.5/layui.js}" charset="utf-8"></script>
<script th:src="@{/layuimini/js/lay-config.js}" charset="utf-8"></script>
<script>
    layui.use([ 'form',"jquery"], function () {
        var $ = layui.jquery,
            form = layui.form;
        form.on('submit(demo1)', function (data) {
            var datas =data.field;
            if(datas.password==datas.password_qd){
                $.ajax({
                    url:"/logininsert",
                    dataType:'json',
                    type:"post",
                    data:{
                        username:datas.username,
                        password:datas.password_qd,
                        remark:datas.desc
                    },
                    success:function (datawql) {
                        alert(datawql.statecode)
                    if(datawql.statecode==200){
                        layer.msg("添加成功！",{icon: 1,time:1500},function () {
                            window.location.reload();
                        })

                    }else {
                        layer.msg("添加失败！",{icon: 2,time:1500})
                    }
                    }

                })

            }else {

                layer.msg("密码不一致！",{time:1500,icon:3})
            }
            return false;
        })


    })
</script>
</body>
</html>
